package com.ziyan.mq;

import com.hmall.common.pojo.Item;
import com.ziyan.service.SearchService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class HMallListener {

    @Autowired
    private SearchService searchService;

    @RabbitListener(queues = MqConstants.HMALL_INSERT_QUEUE)
    public void listenHotelInsertOrUpdate(Item item){
        searchService.insertById(item);
    }


    @RabbitListener(queues = MqConstants.HMALL_DELETE_QUEUE)
    public void listenHotelDelete(Long id){
        searchService.deleteById(id);
    }
}